# -*- coding: utf-8 -*-
"""
@author:  yinbing.li(yinbing.li@zillnk.com)
@version: 1.0.0
@file:    leetcode3_无重复字符的最长子串.py
@time:    2023/3/9 14:04
"""


class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        start = 0
        _max = 0
        st = set()
        for end in range(len(s)):
            while s[end] in st:
                st.remove(s[start])
                start += 1
            st.add(s[end])
            if len(st) > _max:
                _max = len(st)
        return _max


s = Solution()
print(s.lengthOfLongestSubstring("abcabcbb"))
